﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta name="renderer" content="webkit" />
    <meta name="renderer" content="webkit"/>
    <meta name="renderer" content="ie-comp">
    <meta name="renderer" content="ie-stand">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title data-lang="AdminIndex.Blackground_ManageMent"></title>
    <link href="../WFRes/_Content/themes/ligerUI/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <link href="../WFRes/_Content/themes/ligerUI/ligerui-icons.css" rel="stylesheet" type="text/css" />
    <link href="../WFRes/_Content/themes/H3Default/H3-All.css" rel="stylesheet" type="text/css" />
    <link href="../WFRes/assets/stylesheets/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="../WFRes/assets/stylesheets/pixel-admin.min.css" rel="stylesheet" type="text/css" />
    <link rel="shortcut icon" type="image/x-icon" href="../WFRes/images/bitbug_favicon.ico" media="screen" />
    <link rel="icon" type="image/x-icon" href="../WFRes/images/bitbug_favicon.ico" media="screen" />
    <link href="../WFRes/_Content/themes/H3Default/H3-HeadInfo.css" rel="stylesheet" type="text/css" />
    <script src="../WFRes/_Scripts/jquery/jquery.js?v=1.12.4"></script>
    <!--<script src="/Portal/js/aes.js"></script>-->
    <script>
  		//update by hxc@Future
		function htmlEncode(value){
		  return $('<div/>').text(value).html();
		}
		//Html解码获取Html实体
		function htmlDecode(value){
		  return $('<div/>').html(value).text();
		}
    </script>
    <script type="text/javascript">
        var _PORTALROOT_GLOBAL = window.localStorage.getItem("H3.PortalRoot");
        if (!_PORTALROOT_GLOBAL) {
            $.ajax({
                url: "../Index/GetPortalRoot",
                type: "GET",
                cache: false,
                async: false,//同步执行
                dataType: "JSON",
                success: function (data) {
                    if (typeof (data.Extend) != "undefined") {
                        _PORTALROOT_GLOBAL = data.Extend;
                    }
                }
            });
        }
        var ajaxActions = [];
        // 显示登录界面
        var showLogin = function () {
            //var docHeight = ($('body').outerHeight(true) == 0 ? $('body')[0].clientHeight : $('body').outerHeight(true));
            //if (docHeight == 0) docHeight = window.screen.height;
            var loginWin = $.ligerui.get('LoginWinID');
            if (loginWin) {
                loginWin.show();
            }
            else {
                loginWin = $.ligerDialog.open({
                    id: 'LoginWinID',
                    url: _PORTALROOT_GLOBAL + '/index.html#/platform/login',
                    isHidden: false,
                    width: $('body').outerWidth(true),
                    bottom: 0,
                    height: window.screen.height - 105,//docHeight + 20,
                    onClosed: function () {
                        location.reload();
                    }
                });
            }
            $("#LoginWinID").css("bottom", 0);
            loginWin.hideTitle();
            $('body').attr('onresize', '$("body").css("overflow","hidden");$.ligerui.get("LoginWinID").set({width:$("body").outerWidth(true),height:$("body").outerHeight()+14,bottom:0});$("body").css("overflow","auto")')
            .addClass("noscroll");
        }

        var hideLogin = function () {
            $.ligerui.get('LoginWinID').hide();
            $('body').removeClass("noscroll");

            // 再次执行队列中的所有调用
            for (var i = 0; i < ajaxActions.length; i++) {
                $.ajax({
                    url: ajaxActions[i].url,
                    success: ajaxActions[i].success,
                    type: ajaxActions[i].type,
                    dataType: ajaxActions[i].dataType,
                    async: ajaxActions[i].async,
                    cache: ajaxActions[i].cache
                });
            }
            ajaxActions.length = 0;
        }

        $.ajaxSetup({
            beforeSend: function (e, args) {
                // 将当前调用列入队列
                ajaxActions.push({
                    url: args.url,
                    success: args.success,
                    type: args.type,
                    dataType: args.dataType,
                    async: args.async,
                    cache: args.cache
                });
            },
            complete: function (XMLHttpRequest, textStatus) {
                //FormAuthentication过期
                if (XMLHttpRequest.status == 401) {
                    showLogin();
                }
                // 注册统一监听事件
                if (XMLHttpRequest.responseText) {
                    try {
                        var result = JSON.parse(XMLHttpRequest.responseText);
                        if (result && !result.Success && result.ExceptionCode == 1) {
                            // 超时异常
                            showLogin();
                        }
                        else {
                            // 移除队列中的所有调用
                            ajaxActions.length = 0;
                        }
                    } catch (e) { }
                }
            }
        });
    </script>
    <script src="../WFRes/_Scripts/jquery/jquery.lang.js"></script>
    <script src="../WFRes/_Scripts/Calendar/WdatePicker.js" type="text/javascript"></script>
    <script src="../WFRes/_Scripts/ligerUI/ligerui.all.min.js" type="text/javascript"></script>
    <script src="../WFRes/_Scripts/ligerUI/plugins/ligerDrag.js" type="text/javascript"></script>
    <script src="../WFRes/_Scripts/H3AdminPlugins.js" type="text/javascript"></script>
    <script src="../WFRes/_Scripts/H3TreeTools.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
        	//update by ousihang
        	var keysObj = {
        		orgSearchKeys: {
	        		roleCode : "",
	        		roleName : "",
	        		H3TabAutoReload : false
        		}
        	}
        	$.extend(keysObj);
            $("#imgLoginInfo").hover(
                function () {
                    $(".divUserPanel").show();
                },
                function () {
                    $(".divUserPanel").hide();
                });

            $(".divUserPanel").hover(
                function () {
                    $(".divUserPanel").show();
                },
                function () {
                    $(".divUserPanel").hide();
                });

            if (typeof (BizQQWPA) != "undefined" && BizQQWPA) {
                BizQQWPA.addCustom({ //增加自定义外观的WPA
                    aty: '0', //接入类型，0-自动分流，1-指定工号，2-指定分组
                    a: '1001',  //指定接入者，当aty=0时无效
                    nameAccount: '800009266',//营销QQ号
                    selector: 'imgService'//指定成为WPA的元素ID
                });

                BizQQWPA.visitor({  //为页面添加访客功能（主动，自动邀请，TA统计）
                    nameAccount: '800009266'
                });
            }
        });
    </script>
    <script type="text/javascript">
        var workTab = null;
        var leftMenu = null;
        var menuTree = null;
        var tabData = {};
        var tabCount = 0;
        //页面初始化数据
        var pageData = {};

        // TODO:控制器地址，这个地址要统一存放
        var treeDragHandlerUrl = "/PortalTreeDrag";
        $(function () {
            GetPageData();
        });

        // 显示默认页面
        var addDefaultTabs = function (pageData) {
            if (pageData && pageData.defaultTabs) {
                for (var i = 0; i < pageData.defaultTabs.length; i++) {
                    f_addTab(
                    {
                        tabid: pageData.defaultTabs[i].tabid,
                        text: $.Lang(pageData.defaultTabs[i].title),
                        url: pageData.defaultTabs[i].url
                    });
                }
            }
        }

        // 获取页面初始化数据
        function GetPageData() {
            $.ajax({
                url: $.Controller.AdminIndex.GetDefaultPageData,
                type: "GET",
                cache: false,
                async: false,//同步执行
                dataType: "JSON",
                success: function (data) {
                    if (typeof (data) !== "undefined") {
                        pageData = data;
                    }
                    initData(pageData);
                }
            });
        }

        // 渲染获取的服务器端数据
        function initData(data) {
            $("*[data-render]").each(function (n, k) {
                var key = $(this).attr("data-render");
                var keys = key.split(';');
                var id = $(this).attr("id");
                var the = $(this);
                keys.forEach(function (e) {
                    if (data[id + "_" + e] != null) {
                        if (e == "text") {
                            the.text(data[id + "_" + e]);
                        }
                        else {
                            the.attr(e, data[id + "_" + e]);
                        }
                    }
                });
            });

            $.initLanguage();

            ShowLoading();

            if ((!!window.ActiveXObject || "ActiveXObject" in window) || typeof(Worker) !== "undefined") {
            }
            else {
                document.write($.Lang("AdminIndex.WrongBrowsePrompt"));
            }

            //布局
            //布局
            $("#div_Body").ligerLayout({ leftWidth: 218, height: '100%', space: 4, onHeightChanged: f_heightChanged });
            //高度
            var height = $(".l-layout-center").height();
            //Tab
            $("#div_WorkSpace").ligerTab({
                height: height, dragToMove: true, onAfterSelectTabItem: function (tabId) {
                    if (frames[tabId] != null && $.isFunction(frames[tabId].OnPageShown)) {
                        frames[tabId].OnPageShown.call(this, tabId);
                    }
                }
            });
            //显示打开tab列表
            $("#GetMoreTab").click(ShowTabPanel);
            $("#HelpLinkButton").click(HelpLinkButton_Click);
            $("#btnExist").click(btnExist_Click);

            // 绑定树数据
            $("#menuTree").ligerTree({
                checkbox: false,
                width: "100%",
                idFieldName: 'ObjectID',
                textFieldName: 'Text',
                iconFieldName: "Icon",
                btnClickToToggleOnly: true,
                //nodeDraggable :true,
                isExpand: 2,
                url: $.Controller.AdminIndex.LoadTreeData + '?FunctionCode=' + pageData.AdminRootCode,
                isLeaf: function (data) {
                    if (!data) return false;
                    return data.IsLeaf;
                },
                delay: function (e) {
                    var node = e.data;
                    // console.log(node, 'node-------------')
                    // node.TextCode = node.Text;
                    node.TextCode = node.Text;
                    if (node.ExtendObject) {
                        node.Text = node.ExtendObject.Text;
                    }
                    if($.Lang(node.Text) !== null) {
                        node.Text = $.Lang(node.Text);
                    }
                    // if (node.Text === $.Lang(node.Text)) {
                    //     if (node.ExtendObject) {
                    //         node.Text = node.ExtendObject.Text;
                    //     }
                    //     else {
                    //         node.Text = node.Text
                    //     }
                    // } else {
                    //     node.Text = $.Lang(node.Text);
                    // }
                    if (node == null) return false;
                    if (node.IsLeaf == null) return false;
                    if (node.LoadDataUrl == null) return false;
                    if (!node.IsLeaf && node.children == null) {
                        return node.LoadDataUrl;
                    }
                    return false;
                },
                onSelect: f_NodeClick,
                onCancelselect: f_NodeClick,
                onMouseOver: function (node, e) {
                    //鼠标移动上去的效果
                    // //console.log(node, e, '鼠标移入')
                    ItemOver(node, e);
                },
                onMouseOut: function (node, e) {
                    //鼠标移开的效果
                    ItemOut(node, e);
                },
                onAfterAppend: function (node, e) {
                    $(node).find(".l-tree-icon").each(function (n, o) {
                        var l = $(this).offset().left + $(this).width() - 6;
                        $(this).next("span").css("padding-left", l);
                    });
                }
            });
            workTab = $("#div_WorkSpace").ligerGetTabManager();
            menuTree = $("#menuTree").ligerGetTreeManager();
            workTab.setTabButton = setTabButton;
            workTab.removeTabItem = removeTabItem;
            workTab.removeAll = removeAll;
            workTab.removeOther = removeOther;
            workTab.reload = reload;

            // 添加默认展示页面
            addDefaultTabs(pageData);
            $("#treeToolbar").hide();
            $("#historyDiv").hide();

            // 加载完成隐藏等待框
            HideLoading();
        }

        //节点点击
        function f_NodeClick(node) {
            // //console.log(node, '节点点击');
            if (node == null) return;
            if (node.data == null) return;
            //选中后，添加工具栏
            // CreateToolBar(node.data, node.target);
            if (!node.data.ShowPageUrl) return;
            var tabid = $(node.target).attr("tabid");
            var parentID = node.data.ParentID;
            var text = node.data.Text;
            if (parentID != null) {
                var parentData = top.menuTree.getDataByID(parentID);
                text = parentData == null ? text : parentData.Text + "." + text;
            }
            if (!tabid) {
                tabid = node.data.ObjectID;//new Date().getTime();
                $(node.target).attr("tabid", tabid)
            }

            f_addTab(
                {
                    tabid: tabid,
                    code: node.data.Code,
                    text: text,
                    url: node.data.ShowPageUrl
                });
        }

        // 添加Tab页
        function f_addTab(options) {
            if (options.url.toLowerCase().indexOf("welcome/") === -1) {
                options.url = "TabMaster.html?url=" + options.url + "&code=" + encodeURIComponent(options.code);
                // //console.log(options.url)
            }

            if (!tabData.hasOwnProperty(options.tabid)) {
                tabData[options.tabid] = options;
                tabCount++;
            }
            // //console.log(options)
            workTab.addTabItem(options);
        }

        // 重写setTabButton事件，原来是设置左右的按钮，现在改为设置tab数量
        function setTabButton() {
            var g = this, p = this.options;
            var sumwidth = 0;
            $("li", g.tab.links.ul).each(function () {
                sumwidth += $(this).width() + 2;
            });
            //减去头部按钮宽度
            var mainwidth = g.tab.width() - $("#headerButton").width() - 100;
            if (sumwidth > mainwidth) {
                var removeTabId = "";
                var contexts = $(".l-tab-content-item", g.tab.content);
                for (var i = 0, j = contexts.length - 1; i < j; i++) {
                    if ($("iframe", contexts[i])[0].src.toLowerCase().indexOf("/designer.aspx") < 0
                        && $("iframe", contexts[i])[0].src.toLowerCase().indexOf("/sheetdesigner.aspx") < 0) {
                        removeTabId = $(contexts[i]).attr("tabid");
                        break;
                    }
                }
                if (removeTabId === "") {
                    $.H3Dialog.Warn({ content: $.Lang("AdminIndex.NeedCloseTabPage") });
                    g.removeTabItem($("li:last", g.tab.links.ul).attr("tabid"));
                }
                else
                    g.removeTabItem(removeTabId, true);//$("li:first", g.tab.links.ul).attr("tabid"), true);
                return true;
            } else {
                g.tab.links.ul.animate({ left: 0 });
                $(".l-tab-links-left,.l-tab-links-right", g.tab.links).remove();
                return false;
            }
        }

        // 重新加载tab项
        function reload(tabid) {
            var g = this, p = this.options;
            if (g.trigger('beforeReloadTabItem' + tabid, [tabid]) == false)
                return false;

            var contentitem = $(".l-tab-content-item[tabid=" + tabid + "]");
            var iframeloading = $(".l-tab-loading:first", contentitem);
            var iframe = $("iframe:first", contentitem);
            var url = $(iframe).attr("src");
            iframeloading.show();
            iframe.attr("src", url).unbind('load.tab').bind('load.tab', function () {
                iframeloading.hide();
            });
        }

        // 重写移除tab项
        function removeTabItem(tabid, notRemoveData) {
            var g = this, p = this.options;
            if (g.trigger('beforeRemoveTabItem' + tabid, [tabid]) == false)
                return false;
            var currentIsSelected = $("li[tabid=" + tabid + "]", g.tab.links.ul).hasClass("l-selected");
            if (currentIsSelected) {
                $(".l-tab-content-item[tabid=" + tabid + "]", g.tab.content).prev().show();
                $("li[tabid=" + tabid + "]", g.tab.links.ul).prev().addClass("l-selected").siblings().removeClass("l-selected");
            }
            var contentItem = $(".l-tab-content-item[tabid=" + tabid + "]", g.tab.content);
            var jframe = $('iframe', contentItem);
            if (jframe.length) {
                var frame = jframe[0];
                frame.src = "about:blank";
                frame.contentWindow.document.write('');
                frame.contentWindow.close();//chc
                $.browser.msie && CollectGarbage();
                jframe.remove();
            }
            contentItem.remove();
            $("li[tabid=" + tabid + "]", g.tab.links.ul).remove();
            g.setTabButton();
            g.trigger('afterRemoveTabItem', [tabid]);

            if (notRemoveData == null || notRemoveData == false) {
                if (tabData.hasOwnProperty(tabid)) {
                    delete tabData[tabid];
                    tabCount--;
                }
            }
        }
        // 重写移除所有tab
        function removeAll(compel) {
            tabCount = 0;
            tabData = {};
            var g = this, p = this.options;
            var tabidlist = g.getTabidList(null, true);
            $(tabidlist).each(function () {
                g.removeTabItem(this);
            });
        }

        // 重写移除其他所有tab
        function removeOther(tabid, compel) {
            for (var tabkey in tabData) {
                if (tabkey != tabid) {
                    delete tabData[tabkey];
                }
            }
            tabCount = 1;
            var g = this, p = this.options;
            var tabidlist = g.getTabidList(tabid, true);
            $(tabidlist).each(function () {
                g.removeTabItem(this);
            });
        }

        // 高度控制
        function f_heightChanged(options) {
            if (workTab)
                workTab.addHeight(options.diff);
            //if (leftMenu && options.middleHeight - 24 > 0)
            //    leftMenu.setHeight(options.middleHeight - 24);
        }

        // 刷新当前tab页对应的上级节点
        function ReloadNode(parentID) {
            try {
                if (!parentID) {
                    var tabID = workTab.getSelectedTabItemID();
                    var curentNode = tabID == null ? menuTree.getSelected().data : menuTree.getDataByID(tabID);

                    parentID = curentNode.ParentID;
                }
                var nodeData = menuTree.getDataByID(parentID);
                var nodeTarget = menuTree.getNodeDom(nodeData);
                $(nodeTarget).find(".l-children").remove();

                var RemoveNodeFun = function (children) {
                    for (var i = 0; i < children.length; i++) {
                        for (var j = 0; j < top.menuTree.nodes.length; j++) {
                            if (top.menuTree.nodes[j]["treedataindex"] == children[i].treedataindex) {
                                top.menuTree.nodes.splice(j, 1);
                                if (children[i].children != null)
                                    if (RemoveNodeFun(children[i].children));
                                break;
                            }
                        }
                    }
                };
                if (nodeData.children != null) {
                    RemoveNodeFun(nodeData.children);
                }
                $(nodeTarget).find(".l-expandable-close").addClass("l-expandable-open").removeClass("l-expandable-close");
                top.menuTree.loadData(nodeTarget, nodeData.LoadDataUrl);
            }
            catch (e) { }
        }

        // 显示已经打开的tab列表
        function ShowTabPanel() {
            if (tabCount < 1) {
                return;
            }
            var ulObj = $("#tabDataList");
            ulObj.html("");
            // //console.log(tabData, 'tabData')
            for (var tab in tabData) {
                var liObj = $("<li tabDataID='" + tab + "'>" + tabData[tab].text + "</li>");
                liObj.hover(function () { $(this).addClass("hoveli"); }, function () { $(this).removeClass("hoveli"); });
                liObj.click(function () {
                    f_addTab(tabData[$(this).attr("tabDataID")]);
                });
                ulObj.append(liObj);
            }
            ulObj.css("position", "absolute");
            ulObj.css("top", $("#headerButton").offset().top + $("#headerButton").height());
            ulObj.css("left", $("#headerButton").offset().left - ulObj.width() - 2);
            ulObj.css("z-index", 999);
            ulObj.show();
            ulObj.hover(function () { $("#tabDataList").show(); }, RemoveTabPanel);
        }

        // 隐藏tab列表
        function RemoveTabPanel() {
            $("#tabDataList").hide();
        }

        function HelpLinkButton_Click() {
            //console.log(111);
            var helpcode = "";
            if (tabCount > 0) {
                var tabID = workTab.getSelectedTabItemID();

                var fromIndex = tabData[tabID].url.lastIndexOf("/");
                var toIndex = tabData[tabID].url.indexOf(".", fromIndex);
                if (toIndex === -1) {
                    toIndex = tabData[tabID].url.length;
                }
                helpcode = tabData[tabID].url.substring(fromIndex + 1, toIndex);
            }

            var wikiUrl = "http://wiki.h3yun.com/Default.aspx?code=";// $.Lang("AdminIndex.WikiUrl");
            if (wikiUrl !== "") {
                window.open(wikiUrl + helpcode);
            }
            else {
                $.H3Dialog.Warn({ content: $.Lang("NotconfiguredHelpSiteurl") });
            }
        }

        function btnExist_Click() {
            //console.log(111);
            $.ajax({
                url: $.Controller.Organization.LoginOut,
                async:false,
                success: function () {
                    window.location.reload();
                }
            });
        }
    </script>
    <style>
        header {
            background-color: rgb(65, 65, 65) !important;
        }

        .l-tree .l-body span {
            float: none;
        }

        .l-layout-header {
            height: 26px;
        }

        body {
            color: #4997D6;
        }

        .disabled {
            color: #CCC;
        }
    </style>


</head>
<body>
    <form id="form1">
        <div id="treeToolbar"></div>
        <div id="historyDiv"></div>
        <ul id='tabDataList' class="List_ulCss"></ul>
        <header>
            <div id="headerButton" class="header">
                <div>
                    <!--<div id="GetMoreTab" class="headerFun">>></div>-->
                    <img id="HelpLinkButton" alt="帮助" data-title="AdminIndex.Setting_Help" src="../WFRes/_Content/themes/H3Default/Images/help.jpg" class="imgCss" />
                    <img id="imgLoginInfo" src="../WFRes/_Content/themes/H3Default/Images/LoginInfo.png" class="imgCss" />
                    <div class="l-bar-separator"></div>
                    <input type="image" name="btnExist" id="btnExist" class="imgCss" alt="退出" data-title="AdminIndex.Top_Exit" src="../WFRes/_Content/themes/H3Default/Images/LoginOut.png" style="border-width:0px;" />
                </div>
                <div class="divUserPanel">
                    <div class="topP" style="text-align: right; padding-right: 19.5px;">◆</div>
                    <div class="divUserPanel_Warp">
                        <div class="divFace">
                            <img id="imgUser" alt="face" data-render="src" class="d_face" style="border-width:0px;height:120px;width:100px;" />
                        </div>
                        <div class="divDetail">
                            <strong class="d_alias">
                                <span id="lblUserInfo" data-render="text;" class="linkItem"></span>
                            </strong>
                            <p class="d_mobile"><span data-lang="AdminIndex.MobileLogin_UserMobile"></span>:<span id="lblMobile" data-render="text"></span></p>
                            <p class="d_offtel"><span data-lang="AdminIndex.MobileLogin_OfficePhone"></span>:<span id="lblOfficePhone" data-render="text"></span></p>
                            <p class="d_email"><span data-lang="AdminIndex.MobileLogin_Email"></span>:<span id="lblEmail" data-render="text"></span></p>
                        </div>
                    </div>
                    <div class="bottomP" style="display: none;">◆</div>
                </div>
            </div>
        </header>
        <div id="div_Body" style="width: 99.2%; margin: 0 auto;">
            <div position="left" title="
                <a href='../index.html#/app/Workflow/MyUnfinishedWorkItem'
                target='_blank'>
                <img style='height: 20px;width:90px;
                margin-bottom: 3px;
                margin-left: 10px;'
                src='../WFRes/assets/images/pixel-admin/H3BPM.png' />
                </a>" id="div_leftMenu">
                <ul id="menuTree" style="margin-top: 3px; width: 100%;"></ul>
            </div>
            <div position="center" title="" id="div_WorkSpace">
            </div>
        </div>
    </form>
</body>
</html>
